package n2828;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static class Node{
		int left,right;
		int num;
	}
	
	static int MAXN=200000;
	
	static Node[] arr=new Node[4*MAXN];
	static {
		for(int i=0;i<arr.length;i++)arr[i]=new Node();
	}
	static void build(int index,int left,int right)
	{
		arr[index].left=left;
		arr[index].right=right;
		arr[index].num=right-left+1;
		if(left==right)return;
		int mid=(left+right)>>1;
		build(index*2,left,mid);
		build(index*2+1,mid+1,right);
	}
	
	static int update(int index,int pos)
	{
		arr[index].num--;
		if(arr[index].left==arr[index].right)
		{
			return arr[index].left;
		}
		if(arr[index*2].num>=pos) {
			return update(index*2,pos);
		}else {
			pos-=arr[index*2].num;
			return update(index*2+1,pos);
		}
	}
	
	static int posval[][]=new int[MAXN][2];
	
	static int ans[]=new int[MAXN];
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		String line=null;
		while((line=bf.readLine())!=null)
		{
			int n=Integer.parseInt(line);
			build(1, 1, n);
			for(int i=0;i<n;i++)
			{
				line=bf.readLine();
				StringTokenizer st=new StringTokenizer(line);
				posval[i][0]=Integer.parseInt(st.nextToken());
				posval[i][1]=Integer.parseInt(st.nextToken());
			}
			for(int i=n-1;i>=0;i--)
			{
				int k=update(1, posval[i][0]+1);
				ans[k-1]=posval[i][1];
			}
			
			for(int i=0;i<n;i++)
			{
				System.out.print(ans[i]+(i!=n-1?" ":"\n"));
			}
		}
		
	}

}
